package com.serviceprovider.business.utility;

//~--- JDK imports ------------------------------------------------------------

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPool {
    private static final int DEFAULT_THREAD_POOL = 3;
    private ExecutorService  executorService;

    public ThreadPool() {
        executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL);
    }

    public ThreadPool(int poolSize) {
        executorService = Executors.newFixedThreadPool(poolSize);
    }

    public void run(Runnable command) {
        executorService.execute(command);
    }

    public void shutdown() {
        executorService.shutdown();
    }

    public void shutdownNow() {
        executorService.shutdownNow();
    }

    public boolean isShutdown() {
        return executorService.isShutdown();
    }

    public boolean isTerminated() {
        return executorService.isTerminated();
    }
}



